<template>
  <div>
    <div>
      <!-- 工具栏 -->
      <el-button type="primary" icon="el-icon-plus" v-show="!isReadOnly" style="float:right;margin-bottom:5px" @click="addAgenda()">添加</el-button>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :max-height="600" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="selection" width="55px" fixed="left"></el-table-column>
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="name" label="会议议题" width="200px">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name" autocomplete="off" size="small" placeholder="请输入会议议题"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="reportusercode" label="汇报人" width="150px">
          <template slot-scope="scope">
            <tl-ref-user v-model="scope.row.reportusercode" :initDisplayData.sync="scope.row.reportusername" dataType="code" :singleSelect="true" :externalQueryParam="{qry_whereSql:'EXTENDFIELD1 IS NOT NULL AND ENABLED = 1',qry_nodimission:'0'}" ></tl-ref-user>
          </template>
        </el-table-column>
        <el-table-column prop="reportbegintime" label="汇报开始时间" width="170px">
          <template slot-scope="scope">
            <el-date-picker v-model="scope.row.reportbegintime" type="datetime" placeholder="请输入开始时间" format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm" size="small" class="allwidth"> </el-date-picker>
          </template>
        </el-table-column>
        <el-table-column prop="reportendtime" label="汇报时长(分)" width="120px">
          <template slot-scope="scope">
            <el-input v-model="scope.row.reportminutes" type="number" style="80px" autocomplete="off" size="small">分</el-input>
          </template>
        </el-table-column>
        <el-table-column prop="preparematerial" label="内容">
          <template slot-scope="scope">
            <el-input v-model="scope.row.preparematerial" autocomplete="off" size="small" placeholder="请输入内容"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="80px" v-slot="scope" fixed="right">
          <el-button type="text" icon="el-icon-delete" @click="doDeleteAgenda(scope.$index, scope.row)">删除</el-button>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'meetAgenda',
  mixins: [mixin_list],
  components: {},
  data() {
    return {
      description: '会议议程-列表查询',
      urlPrefix: '/meet/agenda/',
      url: {}
    }
  },
  props: {
    isSubPage: {
      type: Boolean,
      default: false
    },
    sourceType: {
      type: String,
      default: 'meetCreate'
    },
    sourceMeetID: {
      type: [Number, String],
      default: ''
    },
    // 是否只读
    isReadOnly: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    /** 增加议程 */
    addAgenda() {
      this.datas.push({
        id: '',
        name: '',
        reportusercode: '',
        reportbegintime: '',
        reportendtime: '',
        preparematerial: ''
      })
    },
    /** 删除议程 */
    doDeleteAgenda(index, row) {
      this.$tap
        .confirm('确定删除数据吗？')
        .then(_ => {
          // 删除,先判断数据库是否存在
          if (row.id !== '') {
            deleteAction(this.url.deleteBatch, { ids: row.id }).then(res => {
              if (res.success) {
                this.datas.splice(index, 1)
              } else {
                this.$tap.alert(res.message, 'warning')
              }
            })
          } else {
            this.datas.splice(index, 1)
          }
        })
        .catch(_ => {})
    }
  }
}
</script>

<style scoped></style>
